home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / comm / mail / YAMscripts.lha / SplitNMail.rexx < prev    next >
OS/2 REXX Batch file  |  1996-11-08  |  3KB  |  92 lines

  1. /*                            Split'n'Mail
  2.                            08-Nov-96 21:22:36
  3.  
  4.   Script for splitting and posting a long ASCII file.
  5.  
  6.   Requirements:
  7.     - YAM 
  8.     - reqtools.library
  9.     - rexxsupport.library
  10.     - rexxreqtools.library
  11.     - a really long ascii file you want to mail
  12.  
  13.   Operation:
  14.     - The script splits the file automatically OR when a line consisting only
  15.       '.break' (without quotes) is encountered.
  16.     - By changing the value of use_separators, you can decide if the parts are
  17.       enclosed between the following lines:
  18.       --- *** --- *** --- *** --- Beginning of part 6 --- *** --- *** --- *** ---
  19.       --- *** --- *** --- *** ---    End of part 6    --- *** --- *** --- *** ---
  20.   
  21.   Send bug reports, comments and hate mail to knikulai@utu.fi.  
  22.  
  23.   If you want to get the list of my AREXX-scripts or their latest versions, 
  24.   send mail to knikulai@utu.fi with subject 'request index'.
  25. */
  26.  
  27. options results
  28. breakline='.break'    /* You can change this to anything you like */
  29. use_separators='yes'    /* This value should be 'yes' or 'no' */
  30. tmp='t:'        /* Temporary files are stored here.  You might want to
  31.                            change this if you are low on memory or the file is 
  32.                very large. */
  33.  
  34. title="Split'n'Mail by knikulai@utu.fi"
  35. butts='_Ok|_Cancel'    /* :-) I know it's childish... :-) */
  36. call addlib('rexxreqtools.library',0,-30)
  37. call addlib('rexxsupport.library',0,-30)
  38.  
  39. email=rtgetstring('','Enter recipients e-mail address',title,butts,,selection)
  40. if selection=0 then call ErrorMsg("You must enter an address!")
  41.  
  42. filename=rtfilerequest('','','Select file to post')
  43. if filename='' | ~exists(filename) then call ErrorMsg("File doesn't exist!")
  44.  
  45. maxl=rtgetlong(400,'How many lines per part?',title,butts,,selection)
  46. if selection=0 | maxl<50 then call ErrorMsg("Too few lines per part!")
  47.  
  48. subj=rtgetstring(filename,'Enter subject of post',title,butts,,selection)
  49. if selection=0 then call ErrorMsg("You must enter a subject!")
  50.  
  51. ok=open(infile,filename,'R')
  52. if ~ok then call ErrorMsg("Can't open file!")
  53.  
  54. fc=1  /* part counter */
  55.  
  56. do while ~eof(infile)
  57.   ok=open(outfile,tmp || fc,'W')
  58.   if ~ok then call ErrorMsg("Could not open file for part "llfc)
  59.   if upper(use_separators)='YES' then call writeln(outfile,'--- *** --- *** --- *** --- Beginning of part '||fc||' --- *** --- *** --- *** ---')
  60.   lc=0 /* line counter */
  61.   do until line=breakline | lc=maxl | eof(infile)
  62.     line=readln(infile)
  63.     lc=lc+1
  64.     if line~=breakline then do
  65.         n=writeln(outfile,line)
  66.     if n<=length(line) then call ErrorMsg("Can't write to file!")
  67.     end
  68.   end /* until line=breakline l lc=maxl */
  69.   if upper(use_separators)='YES' then call writeln(outfile,'--- *** --- *** --- *** ---    End of part '||fc||'    --- *** --- *** --- *** ---')
  70.   call close(outfile)
  71.   if ~eof(infile) then fc=fc+1
  72. end /* until eof(infile) */
  73.  
  74. address 'YAM'
  75. do i=1 to fc
  76.   'WriteMailTo "' || email ||'"'
  77.   'WriteSubject "'|| subj || ' (' || i || '/' || fc || ')"'
  78.   'WriteLetter "' || tmp || i || '"'
  79.   'WriteQueue'
  80.   call delete(tmp || i)
  81. end /* i=1 to fc */
  82.  
  83. call TheEnd /* Goodbye! */
  84.  
  85. ErrorMsg:
  86.     parse arg s
  87.     call rtezrequest(s,"_Exit","Split'n'Mail error")
  88. TheEnd:
  89.     call remlib('rexxreqtools.library')
  90.     call remlib('rexxsupport.library')
  91.     exit /* All good things must eventually come to an end :-) */
  92.